package cn.iocoder.yudao.module.project.dal.mysql.orderdetail;

import java.util.*;

import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
import cn.iocoder.yudao.module.project.dal.dataobject.orderdetail.OrderDetailDO;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.apache.ibatis.annotations.Mapper;
import cn.iocoder.yudao.module.project.controller.admin.orderdetail.vo.*;
import org.apache.ibatis.annotations.Param;

/**
 * 生产订单详情 Mapper
 *
 * @author 芋道源码
 */
@Mapper
public interface OrderDetailMapper extends BaseMapperX<OrderDetailDO> {

    default PageResult<OrderDetailDO> selectPage(OrderDetailPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<OrderDetailDO>()
                .eqIfPresent(OrderDetailDO::getId, reqVO.getId())
                .likeIfPresent(OrderDetailDO::getName, reqVO.getName())
                .eqIfPresent(OrderDetailDO::getPartId, reqVO.getPartId())
                .eqIfPresent(OrderDetailDO::getFlex, reqVO.getFlex())
                .eqIfPresent(OrderDetailDO::getLen, reqVO.getLen())
                .eqIfPresent(OrderDetailDO::getType, reqVO.getType())
                .eqIfPresent(OrderDetailDO::getNum, reqVO.getNum())
                .eqIfPresent(OrderDetailDO::getExpiryDate, reqVO.getExpiryDate())
                .eqIfPresent(OrderDetailDO::getEanCode, reqVO.getEanCode())
                .eqIfPresent(OrderDetailDO::getDrawing, reqVO.getDrawing())
                .eqIfPresent(OrderDetailDO::getTopcoat, reqVO.getTopcoat())
                .betweenIfPresent(OrderDetailDO::getCreateTime, reqVO.getCreateTime())
                .eqIfPresent(OrderDetailDO::getOrderCode, reqVO.getOrderCode())
                .orderByDesc(OrderDetailDO::getId));
    }

    default PageResult<OrderDetailDO> selectPage(OrderDetailPageReqVO reqVO, List<String> orderCodes) {
        return selectPage(reqVO, new LambdaQueryWrapperX<OrderDetailDO>()
                .inIfPresent(OrderDetailDO::getOrderCode,orderCodes)
        );
    }

    List<OrderDetailDO> selectSavedList(Map<String, Object> params);

    void insertList(List<OrderDetailDO> insertList);

    void updateList(List<OrderDetailDO> updateList);

    List<OrderDetailDO> selectOrderDetailPage(Page<OrderDetailPageReqVO> page, @Param("reqVO") OrderDetailPageReqVO pageReqVO);
}